﻿
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>课程订单管理</title>
    <#include "../common/link.ftl">
    <script>
        /*当新增或输入的东西较少时候使用这种弹出框的方法,比较合适*/
        /*页面加载完后,给新增和编辑增加一个点击事件.弹出模块框*/
        $(function () {
            // 用户点击新增或者编辑时候会出现弹出框  $('.btn-input') 这就是编辑新增按钮的class
            $('.btn-input').click(function () {
                // 这一步是为了避免当用户点击新增时候也会出现上一次用户点击编辑时候留下的回显信息
                $('#editForm input').val('');
                $('#editForm option').prop("selected",false);
                $('#userId select').prop("disabled",false);
                // 获取事件源
                var json = $(this).data('json');
                // 如果有json 就是编辑 把这些值输入进去  回显出来
                if(json){
                    $("#editForm input[name=id]").val(json.id);
                    $("#editForm input[name=name]").val(json.name);
                    $("#editForm input[name=money]").val(json.money);
                    $("#editForm select[name='customer.id']").val(json.customer_id);
                    $("#editForm input[name='customer.name']").val(json.customer_name);
                    $("#editForm select[name='course.id']").val(json.course_id);
                    $("#editForm select[name='course.title']").val(json.course_title);
                    $('#userId select').prop("disabled",true)

                }
                // 弹出模块框
                $('#MyModal').modal('show');
            })

          // 使用jquery-form 进行提交异步请求 .当type==submit时候使用ajaxForm
            // 这种方法连事件都不需要
            $("#editForm").ajaxForm(handlerMessage);


// -----------------------------------------------------------------

        })

    </script>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <#--<%@include file="/WEB-INF/views/common/navbar.jsp"%>-->
    <#include "../common/navbar.ftl">
    <!--菜单回显-->
    <#--<c:set var="currentMenu" value="department"/>-->
    <#assign currentMenu="courseOrder"/>
    <#--<%@include file="/WEB-INF/views/common/menu.jsp"%>-->
    <#include "../common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>课程订单管理</h1>
        </section>
        <section class="content" >
            <div class="box">
                <!--高级查询--->
                <div style="margin: 10px;">
                    <form class="form-inline" id="searchForm" action="/courseOrder/list.do" method="post">
                        <input type="hidden" name="currentPage" id="currentPage" value="1">
                        <div class="form-group">
                            <label for="keyWord">关键字:</label>
                            <input type="text"  class="form-control" id="keyWord" name="keyWord" value="${(qo.keyWord)!}" placeholder="请输入客户姓名">
                        </div>
                        <div class="form-group">
                            <label for="courseId"> 销售课程:</label>
                            <select class="form-control" id="courseId" name="courseId">
                                <option value="-1">全部</option>
                                <#list subject as s>
                                    <option value="${s.id}">${(s.title)!}</option>
                                </#list>
                            </select>
                        <#--回显-->
                            <script>
                                $("#courseId option[value='${(qo.courseId)!}']").prop("selected", true);
                            </script>
                        </div>
                        <button id="btn_query" class="btn btn-primary"><span class="glyphicon glyphicon-search"></span> 查询</button>
                        <a href="#" class="btn btn-success btn-input">
                            <span class="glyphicon glyphicon-plus"></span> 添加
                        </a>
                    </form>
                </div>
                <!--编写内容-->
                <div class="box-body table-responsive no-padding ">
                    <table class="table table-hover table-bordered">
                        <tr>
                            <th>编号</th>
                            <th>客户名称</th>
                            <th>销售课程</th>
                            <th>销售时间</th>
                            <th>销售金额</th>
                            <th>操作</th>
                        </tr>
                        <#--<c:forEach items="${pageResult.result}" var="department" varStatus="vs">-->
                            <#list pageResult.list as courseOrder>
                            <tr>
                                <td>${courseOrder_index+1}</td>
                                <td>${(courseOrder.customer.name)!}</td>
                                <td>${(courseOrder.course.title)!}</td>
                                <td>${(courseOrder.inputTime?string("yyyy-MM-dd"))!}</td>
                                <td>${(courseOrder.money)!}</td>
                                <td>
                                    <a href="#"  data-json='${courseOrder.json}'  class="btn btn-info btn-xs btn-input">
                                        <span class="glyphicon glyphicon-pencil"></span> 编辑
                                    </a>
                                </td>
                            </tr>
                    </#list>
                    </table>
                    <#include  "../common/page.ftl">
                </div>
            </div>
        </section>
    </div>
    <#include "../common/footer.ftl">
</div>
<#--新增时候模态框-->
<div class="modal fade" id="MyModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <#--<form class="form-horizontal" action="/courseOrder/saveOrUpdate.do" method="post" id="editForm">-->
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">添加课程订单</h4>
            </div>
                <form class="form-horizontal" action="/courseOrder/saveOrUpdate.do" method="post" id="editForm">
            <div class="modal-body">
                <#--<form class="form-horizontal" action="/courseOrder/saveOrUpdate.do" method="post" id="editForm">-->
                    <input type="hidden" name="id">
                    <div class="form-group" style="margin-top: 10px;">
                        <label for="customer.id" class="col-sm-3 control-label">选择客户：</label>
                        <div  id="userId" class="col-sm-6">
                            <select class="form-control" id="customer.id" name="customer.id">
                                <option value="-1">全部</option>
                                <#list customers as c>
                                    <option value="${c.id}">${(c.name)!}</option>
                                </#list>
                            </select>
                        </div>
                    </div>

                    <div class="form-group" style="margin-top: 10px;">
                        <label for="course.id" class="col-sm-3 control-label">选择课程：</label>
                        <div class="col-sm-6">
                            <select class="form-control" id="course.id" name="course.id">
                                <option value="-1">全部</option>
                                <#list subject as s>
                                    <option value="${s.id}">${(s.title)!}</option>
                                </#list>
                            </select>
                        </div>
            </div>
                        <div class="form-group" style="margin-top: 10px;">
                            <label for="money" class="col-sm-3 control-label">销售金额：</label>
                            <div class="col-sm-6">
                                <input type="text" class="form-control" id="money" name="money"
                                       placeholder="请输入销售金额">
                            </div>
                        </div>

            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="submit" class="btn btn-primary btn-submit">保存</button>
            </div>
            </form>
        </div>
    </div>
</div>

</body>
</html>
